import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import java.io.File;
import java.io.IOException;

@WebServlet("/upload")
@MultipartConfig(location = "C:\\Users\\dell\\Desktop\\xxx\\src\\main\\webapp\\css")
public class Upload extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        HttpSession session=request.getSession(true);
        Part part = request.getPart("file");
        String fileName = part.getSubmittedFileName();
        if(fileName==null || fileName.equals("")) response.sendRedirect("error.jsp");
        part.write(fileName);
        session.setAttribute("path",fileName);
        response.sendRedirect("message.jsp");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
